package com.hqyj.smvc.controller;

import com.github.pagehelper.PageInfo;
import com.hqyj.smvc.pojo.Card;
import com.hqyj.smvc.service.CardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;


import java.util.List;

@Controller
public class CardController {
    @Autowired
    private CardService cardService;

    /**
     * 查看所有身份证
     * @param pageNum 当前页
     * @param model 结果的存放域
     * @return 要跳转的页面
     */
    @GetMapping(value = "showAllCard")
    public String showAllCard(int pageNum, Model model){
        List<Card> cards = cardService.showAllCard(pageNum);
        PageInfo<Card> pageInfo = new PageInfo<>(cards);
        model.addAttribute("cards", cards);
        model.addAttribute("pageInfo", pageInfo);
        return "/WEB-INF/card/showAllCard";
    }

}
